/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package damagecalculator;

import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

/**
 *
 * @author Marcelo
 */
public class RemovableButton extends JButton implements ActionListener {
    
    java.awt.Container container;
    int arrayPos;
    public RemovableButton(String name) {
        super(name);
        init();
    }
    
    private void init() {
        addActionListener(this);
    }
    
    public void setContainer(java.awt.Container c) {
        container = c;
    }
    
    public void setArrayPos(int x) {
        arrayPos = x;
    }
    
   
    public void actionPerformed(ActionEvent e) {
        DamageCalculatorView.BuildButtons[arrayPos] = null;
        container.remove(this);
        container.validate();
        container.repaint();
    }
}
